<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册页面</title>
    <link href="/static/css/style.css" rel="stylesheet" media="screen">
    <link href="/static/layui/css/layui.css" rel="stylesheet" type="text/css"/>
    <style type="text/css">
        .container {
            width: 420px;
            height: 320px;
            min-height: 320px;
            max-height: 320px;
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            margin: auto;
            padding: 20px;
            z-index: 130;
            border-radius: 8px;
            background-color: #fff;
            box-shadow: 0 3px 18px rgba(100, 0, 0, .5);
            font-size: 16px;
        }

        .close {
            background-color: white;
            border: none;
            font-size: 18px;
            margin-left: 410px;
            margin-top: -10px;
        }

        .layui-input {
            border-radius: 5px;
            width: 300px;
            height: 40px;
            font-size: 15px;
        }

        .layui-form-item {
            margin-left: -20px;
        }

        #logoid {
            margin-top: -16px;
            padding-left: 150px;
            padding-bottom: 15px;
        }

        .layui-btn {
            margin-left: -50px;
            border-radius: 5px;
            width: 350px;
            height: 40px;
            font-size: 15px;
        }

        .verity {
            width: 120px;
        }

        .font-set {
            font-size: 13px;
            text-decoration: none;
            margin-left: 120px;
        }

        a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
<div id="particles-js">
    <form class="layui-form" id="form1">
        <div class="container">
            <!--<button class="close" title="关闭">X</button>-->
            <div class="layui-form-mid layui-word-aux">
                <img id="logoid" src="/static/img/logo.jpg" height="35">
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机号</label>
                <div class="layui-input-block">
                    <input type="text" name="aphone" required lay-verify="required" placeholder="请输入用户名"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密 &nbsp;&nbsp;码</label>
                <div class="layui-input-inline">
                    <input type="password" name="apassword" required lay-verify="required" placeholder="请输入密码"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">确认密码</label>
                <div class="layui-input-inline">
                    <input type="password" name="ackpassword" required lay-verify="required" placeholder="请输入密码"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" type="button" id="login" lay-filter="formDemo">注册</button>
                </div>
            </div>
            <a href="index.html" class="font-set">已有账号</a><a href="retrieve.html" class="font-set">忘记密码?</a>
        </div>
    </form>
</div>
<div style="text-align:center;">
</div>
</body>
<script src="/static/layui/layui.js"></script>
<!--登录页调整星空粒子间隔,坐标...-->
<script src="/static/js/particles.min.js"></script>
<script src="/static/js/app.js"></script>
<script src="/static/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['form', 'jquery', 'layer'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        var layer = layui.layer;
        //添加表单失焦事件
        //验证表单
        $('#aphone').blur(function () {
            var aphone = $(this).val();
            //alert(user);
            $.ajax({
                url: '',
                type: 'post',
                dataType: 'text',
                data: {aphone: aphone},
                //验证用户名是否可用
                success: function (data) {
                    if (data.code != 200) {
                        $('#ri').removeAttr('hidden');
                        $('#wr').attr('hidden', 'hidden');
                    } else {
                        $('#wr').removeAttr('hidden');
                        $('#ri').attr('hidden', 'hidden');
                        layer.msg('当前用户名已被占用! ')
                    }
                }
            })

        });
        // you code ...
        // 为密码添加正则验证
        $('#apassword').blur(function () {
            var reg = /^[\w]{6,12}$/;
            if (!($('#apassword').val().match(reg))) {
                //layer.msg('请输入合法密码');
                $('#pwr').removeAttr('hidden');
                $('#pri').attr('hidden', 'hidden');
                layer.msg('请输入合法密码');
            } else {
                $('#pri').removeAttr('hidden');
                $('#pwr').attr('hidden', 'hidden');
            }
        });
        //验证两次密码是否一致
        $('#ackpassword').blur(function () {
            if ($('#ackpassword').val() != $('#ackpassword').val()) {
                $('#rpwr').removeAttr('hidden');
                $('#rpri').attr('hidden', 'hidden');
                layer.msg('两次输入密码不一致!');
            } else {
                $('#rpri').removeAttr('hidden');
                $('#rpwr').attr('hidden', 'hidden');
            }
            ;
        });
        //添加表单监听事件,提交注册信息
        form.on('submit(formDemo)', function () {
            $.ajax({
                url: '',
                type: 'post',
                dataType: 'text',
                data: {
                    user: $('#user').val(),
                    pwd: $('#pwd').val(),
                },
                success: function (data) {
                    if (data.code != 200) {
                        layer.msg('注册成功');
                        ///location.href = "login.html";
                    } else {
                        layer.msg('注册失败');
                    }
                }
            })
            //防止页面跳转
            return false;
        });
    });
</script>
</html>